<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"
    />
    <title>代理模式</title>
    <style lang="css">
        .preload {
            display: block;
            width: 160px;
            height: 160px;
        }
    </style>
</head>

<body>
    <h2>缓存代理</h2>
    <p>缓存代理可以为一些开销大的运算结果提供暂时的存储，在下次运算时，如果传递进来的参 数跟之前一致，则可以直接返回前面存储的运算结果。</p>
    <p>例子：计算乘积</p>
    <script type="text/javascript">
        var mult = function () {
            var result = 1
            for(var i=0;i<arguments.length;i++){
                result = result*arguments[i]
            }
            console.log('计算中...')
            return result
        }
        var test1 = mult(2,3)
        var test2 = mult(2,3,4)
        var test3 = mult(2,3,4)
        console.log(test1)
        console.log(test2)
        console.log(test3)

    </script>

</body>

</html>